﻿using ContentAppBase.Model;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace ContentAppBase.Utils
{
    public class HubItemTemplateSelector : DataTemplateSelector
    {
        public DataTemplate HeroImageTemplate { get; set; }
        public DataTemplate IntroTemplate { get; set; }
        public DataTemplate ImageResultTemplate { get; set; }
        public DataTemplate WebResultTemplate { get; set; }
        public DataTemplate ChapterTemplate { get; set; }

        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            if (item is SimpleItem)
            {
                switch (((SimpleItem)item).Type)
                {
                    case SimpleItemType.Chapter:
                        return ChapterTemplate;
                    case SimpleItemType.HeroImage:
                        return HeroImageTemplate;
                    case SimpleItemType.Intro:
                        return IntroTemplate;
                    case SimpleItemType.ImageResults:
                        return ImageResultTemplate;
                    case SimpleItemType.WebResults:
                        return WebResultTemplate;
                }
            }

            return base.SelectTemplateCore(item, container);
        }
    }
}
